import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

import user from './modules/user'
import artical from './modules/artical'

export default new Vuex.Store({
  state: {
    user: sessionStorage.getItem('name'),
  },
  getters: {},
  mutations: {
    updateUserInfo(state, payload) {
      state.user = payload
      window.sessionStorage.setItem('name', payload)
    }
  },
  actions: {
    login(store, payload) {
      store.commit('updateUserInfo', payload)
    }
  },
  modules: {
    user,
    artical
  }
})